#include "widget.h"
#include "ui_widget.h"
#include <QDebug>
#include <QDir>
#include <QScrollArea>
#include <QGridLayout>

#include <OECommonHelper>
#include "oewalletloginwidget.h"
#include "oewalletselectwidget.h"
Widget::Widget(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::Widget)
{
    ui->setupUi(this);
    QString str = QDir::currentPath();
#if 0
//    QGridLayout* layout = new QGridLayout();
    OEWalletLoginWidget* wallet = new OEWalletLoginWidget();
    wallet->setFixedWidth(901);
    wallet->show();
    qDebug() << wallet->loadWallet(str);
#endif
#if 1

    QScrollArea *scroll= new QScrollArea();
    OEWalletSelectWidget* wallet= new OEWalletSelectWidget();
    wallet->loadWallet(str);
    scroll->setWidget(wallet);

    setCentralWidget(scroll);

#endif

#if 0
    QGridLayout* layout = new QGridLayout();
    layout->addWidget(wallet);
    QScrollArea * scroll = new QScrollArea(this);
    scroll->setBackgroundRole(QPalette::Dark);
//    scroll->setWidget(wallet);
    scroll->setLayout(layout);

    QGridLayout* layout1 = new QGridLayout();
    layout1->addWidget(scroll);
    setLayout(layout1);
#endif
#if 0

    QScrollArea *pArea= new QScrollArea(this);
    OEWalletLoginWidget* mainWdgt= new OEWalletLoginWidget(/*pArea*/);
    pArea->setWidget(mainWdgt);
    mainWdgt->setGeometry(0,0,900,0);
    mainWdgt->loadWallet(QDir::currentPath());
//    pArea->setFixedHeight(100);

//    mainWdgt->setLayout(layout);

//    QGridLayout* temp_layout1 = new QGridLayout();
//    temp_layout1->addWidget(main_wdgt);
//    pArea->setLayout(temp_layout1);


    QGridLayout* temp_layout = new QGridLayout();
    temp_layout->setMargin(0);
    temp_layout->addWidget(pArea);
    setLayout(temp_layout);
#endif

#if 0
    qDebug() << QDir::currentPath();
    qDebug() << QDir::homePath();

    QDir::setCurrent("C:/");
    qDebug() << QDir::currentPath();
    qDebug() << QDir::homePath();
    qDebug() << QDir::home().path();
    qDebug() << QDir::temp().path();
    QDir dir(QDir::currentPath());
    dir.setFilter(QDir::Filter::Dirs);
    QFileInfoList list_dir = dir.entryInfoList();

    qDebug() << "dir count: " << list_dir.count();
    for (auto& dir_iter : list_dir) {
        qDebug() << dir_iter.absoluteFilePath();
    }
#endif
}

Widget::~Widget()
{
    delete ui;
}
